Skip to content

Added consistency checker#14402

Merged
StormLiangMS merged 9 commits intosonic-net:masterfrom
Ryangwaite:add-consistency-checker
Sep 19, 2024
Merged

Added consistency checker#14402
StormLiangMS merged 9 commits intosonic-net:masterfrom
Ryangwaite:add-consistency-checker

Conversation

@Ryangwaite
Copy link
Contributor

@Ryangwaite Ryangwaite commented Sep 3, 2024

Description of PR

Summary:
Added a new consistency checker utility that compares the values in the ASIC_DB with the values in the ASIC itself. It's initially integrated with test_upgrade_path.py.

It works by sending and receiving get request/responses to/from syncd via redis and pysairedis. To enable this, the following patches were made in dependent repositories:

Due to policies around backporting and merging changes to certain mainline branches, we can't merge the above changes in all cases. To support these, there are two flags --consistency_checker_libsairedis_url_template and --consistency_checker_python3_pysairedis_url_template where a templated URL may be provided to download libsairedis and python3-pysairedis debs that have been compiled for the test to be installed on the device.

This is an opt-in check and will only run if the --enable_consistency_checker has been provided.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405

Approach

What is the motivation for this PR?

There was a test gap discovered where the ASIC_DB and ASIC itself were inconsistent after an upgrade resulting in traffic being dropped.

How did you do it?

Created a python fixture called consistency_checker_provider that can be injected into any test and used to call the consistency_checker utility.

How did you verify/test it?

Tested on an internal A->B upgrade scenario.

Any platform specific information?

Currently only supports Arista x86_64-arista_7060_cx32s and x86_64-arista_7260cx3_64 platforms and versions 202305 and 202311. The ConsistencyCheckerProvider.is_consistency_check_supported will return True for a supported combination. Other platforms and versions may very well work they just haven't been tested yet. To try, simply ignore the result of is_consistency_check_supported and carry on with the test.

Supported testbed topology if it's a new test case?

Documentation

Will be added in a follow-up PR.

@Ryangwaite Ryangwaite requested a review from prgeor as a code owner September 3, 2024 11:49
@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/upgrade_path/upgrade_helpers.py

check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/common/fixtures/consistency_checker/consistency_checker.py:46:121: E501 line too long (128 > 120 characters)
tests/common/fixtures/consistency_checker/consistency_checker.py:57:121: E501 line too long (134 > 120 characters)
tests/common/fixtures/consistency_checker/consistency_checker.py:62:121: E501 line too long (144 > 120 characters)
tests/common/fixtures/consistency_checker/consistency_checker.py:83:121: E501 line too long (131 > 120 characters)
tests/common/fixtures/consistency_checker/consistency_checker.py:84:121: E501 line too long (220 > 120 characters)
...
[truncated extra lines, please run pre-commit locally to view full check results]

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/upgrade_path/upgrade_helpers.py

check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/common/fixtures/consistency_checker/consistency_checker.py:46:121: E501 line too long (128 > 120 characters)
tests/common/fixtures/consistency_checker/consistency_checker.py:57:121: E501 line too long (134 > 120 characters)
tests/common/fixtures/consistency_checker/consistency_checker.py:62:121: E501 line too long (144 > 120 characters)
tests/common/fixtures/consistency_checker/consistency_checker.py:83:121: E501 line too long (131 > 120 characters)
tests/common/fixtures/consistency_checker/consistency_checker.py:84:121: E501 line too long (220 > 120 characters)
...
[truncated extra lines, please run pre-commit locally to view full check results]

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/common/fixtures/consistency_checker/query-asic.py
Fixing tests/common/fixtures/consistency_checker/consistency_checker.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/common/fixtures/consistency_checker/consistency_checker.py:43:121: E501 line too long (128 > 120 characters)
tests/common/fixtures/consistency_checker/consistency_checker.py:54:121: E501 line too long (134 > 120 characters)
tests/common/fixtures/consistency_checker/consistency_checker.py:59:121: E501 line too long (144 > 120 characters)
tests/common/fixtures/consistency_checker/consistency_checker.py:218:25: E117 over-indented
...
[truncated extra lines, please run pre-commit locally to view full check results]

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

Copy link
Contributor

@vaibhavhd vaibhavhd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non blocking comments added.


if self._python3_pysairedis_download_url is not None:
# Install python3-sairedis in syncd container
self._duthost.shell((f"docker exec {SYNCD_CONTAINER} bash -c "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEB installation failures are not caught and not logged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kwarg module_ignore_errors kwarg is implicitly False here. So if the deb installation fails an error will be raised with the failing command. I don't think we should catch and log and continue.

finally:
uninitialize_sai_api()

print(json.dumps(results))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will print to stdout. Why is logger not used?

logger.info("Initializing SAI API")
profileMap = dict()
profileMap[pysairedis.SAI_REDIS_KEY_ENABLE_CLIENT] = "true"
status = pysairedis.sai_api_initialize(0, profileMap)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking for pysairedis - is 0 for flags which should be zero as per sai spec?

https://github.com/opencomputeproject/SAI/blob/a0ae84d9366d35bfc50738c3b29e03387bf85c7c/inc/sai.h#L226

@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/common/fixtures/consistency_checker/query-asic/parser.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/common/fixtures/consistency_checker/consistency_checker.py:19:22: E222 multiple spaces after operator
tests/common/fixtures/consistency_checker/query-asic/query-asic.py:155:25: E128 continuation line under-indented for visual indent
tests/common/fixtures/consistency_checker/query-asic/query-asic.py:170:26: E128 continuation line under-indented for visual indent

flake8...............................................(no files to check)Skipped
...
[truncated extra lines, please run pre-commit locally to view full check results]

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@Ryangwaite Ryangwaite force-pushed the add-consistency-checker branch from 36b6e1c to ce433ae Compare September 13, 2024 06:42
@Ryangwaite Ryangwaite force-pushed the add-consistency-checker branch from bf8d1d3 to f0aeb36 Compare September 15, 2024 23:26
@StormLiangMS StormLiangMS merged commit 62253d5 into sonic-net:master Sep 19, 2024
@StormLiangMS
Copy link
Collaborator

StormLiangMS commented Sep 19, 2024

hi @Ryangwaite could you confirm this is tested with 202311 and 202405 branch for cherry pick? Would like to avoid regression.

hdwhdw pushed a commit to hdwhdw/sonic-mgmt that referenced this pull request Sep 20, 2024
What is the motivation for this PR?
There was a test gap discovered where the ASIC_DB and ASIC itself were inconsistent after an upgrade resulting in traffic being dropped.

How did you do it?
Created a python fixture called consistency_checker_provider that can be injected into any test and used to call the consistency_checker utility.

How did you verify/test it?
Tested on an internal A->B upgrade scenario.

Any platform specific information?
Currently only supports Arista x86_64-arista_7060_cx32s and x86_64-arista_7260cx3_64 platforms and versions 202305 and 202311. The ConsistencyCheckerProvider.is_consistency_check_supported will return True for a supported combination. Other platforms and versions may very well work they just haven't been tested yet. To try, simply ignore the result of is_consistency_check_supported and carry on with the test.
arista-hpandya pushed a commit to arista-hpandya/sonic-mgmt that referenced this pull request Oct 2, 2024
What is the motivation for this PR?
There was a test gap discovered where the ASIC_DB and ASIC itself were inconsistent after an upgrade resulting in traffic being dropped.

How did you do it?
Created a python fixture called consistency_checker_provider that can be injected into any test and used to call the consistency_checker utility.

How did you verify/test it?
Tested on an internal A->B upgrade scenario.

Any platform specific information?
Currently only supports Arista x86_64-arista_7060_cx32s and x86_64-arista_7260cx3_64 platforms and versions 202305 and 202311. The ConsistencyCheckerProvider.is_consistency_check_supported will return True for a supported combination. Other platforms and versions may very well work they just haven't been tested yet. To try, simply ignore the result of is_consistency_check_supported and carry on with the test.
vikshaw-Nokia pushed a commit to vikshaw-Nokia/sonic-mgmt that referenced this pull request Oct 23, 2024
What is the motivation for this PR?
There was a test gap discovered where the ASIC_DB and ASIC itself were inconsistent after an upgrade resulting in traffic being dropped.

How did you do it?
Created a python fixture called consistency_checker_provider that can be injected into any test and used to call the consistency_checker utility.

How did you verify/test it?
Tested on an internal A->B upgrade scenario.

Any platform specific information?
Currently only supports Arista x86_64-arista_7060_cx32s and x86_64-arista_7260cx3_64 platforms and versions 202305 and 202311. The ConsistencyCheckerProvider.is_consistency_check_supported will return True for a supported combination. Other platforms and versions may very well work they just haven't been tested yet. To try, simply ignore the result of is_consistency_check_supported and carry on with the test.
Ryangwaite added a commit to Ryangwaite/sonic-mgmt that referenced this pull request Apr 28, 2025
What is the motivation for this PR?
There was a test gap discovered where the ASIC_DB and ASIC itself were inconsistent after an upgrade resulting in traffic being dropped.

How did you do it?
Created a python fixture called consistency_checker_provider that can be injected into any test and used to call the consistency_checker utility.

How did you verify/test it?
Tested on an internal A->B upgrade scenario.

Any platform specific information?
Currently only supports Arista x86_64-arista_7060_cx32s and x86_64-arista_7260cx3_64 platforms and versions 202305 and 202311. The ConsistencyCheckerProvider.is_consistency_check_supported will return True for a supported combination. Other platforms and versions may very well work they just haven't been tested yet. To try, simply ignore the result of is_consistency_check_supported and carry on with the test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants